<template>
  <span class="iconfont icon-fanhuijiantou ico"></span>

  <h1>设置昵称与密码</h1>

  <div class="usermsg">
    <input placeholder="QQ号码" v-model="num" type="text">
    <input placeholder="密码" v-model="password" type="password">
    <div @click="isSignIn">注册</div>
  </div>
</template>

<script setup>
  import {ref} from 'vue'
  import { useRouter } from 'vue-router'
  import { useStore } from 'vuex';
  import { Dialog } from 'vant';

  const router = useRouter()
  const store = useStore()
  const password = ref()
  const num = ref()
  
  const isSignIn = () => {
    num.value ? password.value ? signIn({
      num: num.value*1,
      password: password.value*1
    }) : Dialog.alert({
      message: '请输入密码'
    }) : Dialog.alert({
      message: '请输入QQ号码'
    })
  }

  const signIn = (userInfo) => {
    store.dispatch('signIn',userInfo)
    router.go(-1)
    console.log(store.state.users)
  }
</script>

<style scoped>
  .ico {
    position: fixed;
    top: 15px;
    left: 10px;
    font-size: 30px;
  }

  h1 {
    margin: 55px 0 30px 30px;
    font-weight: 500;
  }

  .usermsg {
    display: flex;
    flex-direction: column;
    width: 345px;
    margin: 0 15px;
  }

  .usermsg input {
    width: 340px;
    height: 40px;
    border: 0;
    outline: none;
    border-bottom: 1px solid black;
  }

  .usermsg div {
    height: 40px;
    margin-top: 30px;
    line-height: 40px;
    text-align: center;
    font-size: 18px;
    color: aliceblue;
    font-weight: 500;
    border-radius: 15px;
    background-color: aqua;
  }


</style>